package com.bdqn.rabbitmq;

import com.bdqn.base.Email;
import com.bdqn.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * EmailRabbitMQServiceImpl
 *
 * @author LILIBO
 * @since 2023-03-23
 */
@Service
public class EmailRabbitMQServiceImpl implements EmailRabbitMQService {

    /**
     * 引入RabbitMQ操作对象
     */
    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 将邮件消息推送到RabbitMQ消息队列
     *
     * @param email
     */
    public void publishMQMail(Email email) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE_NAME_EMAIL, RabbitMQConfig.ROUTING_KEY_EMAIL, email);
    }
}
